package com.fire.chat.init;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CountDownLatch;

/**
 * @program: hxzq
 * @description: 异步初始化抽象
 * @author: xjr
 * @create: 2020-11-04 15:12
 **/
@Slf4j
public abstract class AbstractAsyncAppStartEvent implements AsyncAppStartEvent {

    private CountDownLatch count;


    @Override
    public void setCount(CountDownLatch count) {
        this.count = count;
    }

    @Override
    public void run() {
        log.info("------------------------------------------开始执行初始化任务:{}-----------------------------------------",taskName());
        try {
            init();
        } catch (Throwable throwable) {
            log.error("------------------------------------------任务{}执行出错,具体原因{}",taskName(),throwable.getMessage());
        }finally {
            count.countDown();
        }
    }
}
